<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Linear Regression</title>
<link rel="stylesheet" href="../math.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../index.html" title="Math Toolkit 4.2.1">
<link rel="up" href="../statistics.html" title="Chapter 6. Statistics">
<link rel="prev" href="ljung_box.html" title="The Ljung-Box Test">
<link rel="next" href="chatterjee_correlation.html" title="Chatterjee Correlation">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
<td align="center"><a href="../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="ljung_box.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../statistics.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="chatterjee_correlation.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="math_toolkit.linear_regression"></a><a class="link" href="linear_regression.html" title="Linear Regression">Linear Regression</a>
</h2></div></div></div>
<h4>
<a name="math_toolkit.linear_regression.h0"></a>
      <span class="phrase"><a name="math_toolkit.linear_regression.synopsis"></a></span><a class="link" href="linear_regression.html#math_toolkit.linear_regression.synopsis">Synopsis</a>
    </h4>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">statistics</span><span class="special">/</span><span class="identifier">linear_regression</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>

<span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">statistics</span> <span class="special">{</span>

<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">RandomAccessContainer</span><span class="special">&gt;</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special">&lt;</span><span class="identifier">Real</span><span class="special">,</span> <span class="identifier">Real</span><span class="special">&gt;</span> <span class="identifier">simple_ordinary_least_squares</span><span class="special">(</span><span class="identifier">RandomAccessContainer</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">x</span><span class="special">,</span>
                                                    <span class="identifier">RandomAccessContainer</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">y</span><span class="special">);</span>

<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">RandomAccessContainer</span><span class="special">&gt;</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">tuple</span><span class="special">&lt;</span><span class="identifier">Real</span><span class="special">,</span> <span class="identifier">Real</span><span class="special">,</span> <span class="identifier">Real</span><span class="special">&gt;</span> <span class="identifier">simple_ordinary_least_squares_with_R_squared</span><span class="special">(</span><span class="identifier">RandomAccessContainer</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">x</span><span class="special">,</span>
                                                                          <span class="identifier">RandomAccessContainer</span> <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">y</span><span class="special">);</span>

<span class="special">}}}</span>
</pre>
<h4>
<a name="math_toolkit.linear_regression.h1"></a>
      <span class="phrase"><a name="math_toolkit.linear_regression.background"></a></span><a class="link" href="linear_regression.html#math_toolkit.linear_regression.background">Background</a>
    </h4>
<p>
      A simple ordinary least squares finds the numbers <span class="emphasis"><em>c</em></span><sub>0</sub> and
      <span class="emphasis"><em>c</em></span><sub>1</sub> which minimizes the merit function
    </p>
<p>
      <span class="inlinemediaobject"><object type="image/svg+xml" data="../../graphs/simple_ordinary_least_squares_merit.svg" width="246" height="54"></object></span>
    </p>
<p>
      The predictive model generated from the minima of this functional is <span class="emphasis"><em>f</em></span>(<span class="emphasis"><em>x</em></span>)
      = <span class="emphasis"><em>c</em></span><sub>0</sub> + <span class="emphasis"><em>c</em></span><sub>1</sub> <span class="emphasis"><em>x</em></span>.
    </p>
<p>
      It turns out that numerically, computing the numbers <span class="emphasis"><em>c</em></span><sub>0</sub> and
      <span class="emphasis"><em>c</em></span><sub>1</sub> is not <span class="emphasis"><em>quite</em></span> trivial. See <a href="https://www.johndcook.com/blog/2008/10/20/comparing-two-ways-to-fit-a-line-to-data/" target="_top">here</a>
      for an explanation of some ways linear regression can go wrong. A better method
      of computing the model parameters uses one-pass, numerically stable methods
      to compute means, variances, and covariances, and then assembles the parameters
      from these.
    </p>
<p>
      An example usage of the simple linear regression is given below:
    </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">vector</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">iostream</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">statistics</span><span class="special">/</span><span class="identifier">linear_regression</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>

<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> <span class="special">{</span>
    <span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">statistics</span><span class="special">::</span><span class="identifier">simple_ordinary_least_squares</span><span class="special">;</span>
    <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;</span> <span class="identifier">x</span><span class="special">{</span><span class="number">1</span><span class="special">,</span> <span class="number">3</span><span class="special">,</span> <span class="number">7</span><span class="special">,</span> <span class="number">12</span><span class="special">};</span>
    <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;</span> <span class="identifier">y</span><span class="special">{</span><span class="number">8</span><span class="special">,</span><span class="number">13</span><span class="special">,</span> <span class="number">26</span><span class="special">,</span> <span class="number">35</span><span class="special">};</span>

    <span class="keyword">auto</span> <span class="special">[</span><span class="identifier">c0</span><span class="special">,</span> <span class="identifier">c1</span><span class="special">]</span> <span class="special">=</span> <span class="identifier">simple_ordinary_least_squares</span><span class="special">(</span><span class="identifier">x</span><span class="special">,</span> <span class="identifier">y</span><span class="special">);</span>
    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"f(x) = "</span> <span class="special">&lt;&lt;</span> <span class="identifier">c0</span> <span class="special">&lt;&lt;</span> <span class="string">" + "</span> <span class="special">&lt;&lt;</span> <span class="identifier">c1</span> <span class="special">&lt;&lt;</span> <span class="string">"*x"</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</span><span class="special">;</span>
    <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="string">"f(2) = "</span> <span class="special">&lt;&lt;</span> <span class="identifier">c0</span> <span class="special">+</span> <span class="identifier">c1</span><span class="special">*</span><span class="number">2</span> <span class="special">&lt;&lt;</span> <span class="string">"\n"</span><span class="special">;</span>
<span class="special">}</span>
<span class="comment">// Output:</span>
<span class="identifier">f</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span> <span class="special">=</span> <span class="number">6.0742</span> <span class="special">+</span> <span class="number">2.50883</span><span class="special">*</span><span class="identifier">x</span>
<span class="identifier">f</span><span class="special">(</span><span class="number">2</span><span class="special">)</span> <span class="special">=</span> <span class="number">11.0919</span>
</pre>
<p>
      If, in addition, you wish to assess how appropriate linear regression is for
      your data, you can calculate <span class="emphasis"><em>R</em></span><sup>2</sup> as well, via
    </p>
<pre class="programlisting"><span class="keyword">auto</span> <span class="special">[</span><span class="identifier">c0</span><span class="special">,</span> <span class="identifier">c1</span><span class="special">,</span> <span class="identifier">R2</span><span class="special">]</span> <span class="special">=</span> <span class="identifier">simple_ordinary_least_squares_with_R_squared</span><span class="special">(</span><span class="identifier">x</span><span class="special">,</span> <span class="identifier">y</span><span class="special">);</span>
</pre>
<p>
      It seems a number of definitions exist for <span class="emphasis"><em>R</em></span><sup>2</sup>; we use
    </p>
<p>
      <span class="inlinemediaobject"><object type="image/svg+xml" data="../../graphs/r_squared_definition.svg" width="259" height="54"></object></span>
    </p>
<p>
      The fit is good if <span class="emphasis"><em>R</em></span><sup>2</sup> is close to 1.
    </p>
<h4>
<a name="math_toolkit.linear_regression.h2"></a>
      <span class="phrase"><a name="math_toolkit.linear_regression.performance"></a></span><a class="link" href="linear_regression.html#math_toolkit.linear_regression.performance">Performance</a>
    </h4>
<p>
      There are two cases: When you want to compute <span class="emphasis"><em>R</em></span><sup>2</sup>, and
      when you don't want to simultaneously compute <span class="emphasis"><em>R</em></span><sup>2</sup>, although
      the cost of computing <span class="emphasis"><em>R</em></span><sup>2</sup> is not high:
    </p>
<pre class="programlisting"><span class="special">-----------------------------------------------------------------------------------------------------------------</span>
<span class="identifier">Benchmark</span>                                                       <span class="identifier">Time</span>  <span class="identifier">Bytes</span><span class="special">/</span><span class="identifier">second</span>
<span class="special">-----------------------------------------------------------------------------------------------------------------</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">8</span>                        <span class="number">51.9</span> <span class="identifier">ns</span>  <span class="number">588.476</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">16</span>                        <span class="number">112</span> <span class="identifier">ns</span>  <span class="number">546.087</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">32</span>                        <span class="number">277</span> <span class="identifier">ns</span>  <span class="number">440.823</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">64</span>                        <span class="number">608</span> <span class="identifier">ns</span>  <span class="number">401.659</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">128</span>                      <span class="number">1276</span> <span class="identifier">ns</span>  <span class="number">382.622</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">256</span>                      <span class="number">2606</span> <span class="identifier">ns</span>  <span class="number">374.748</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">512</span>                      <span class="number">5266</span> <span class="identifier">ns</span>  <span class="number">370.868</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">1024</span>                    <span class="number">10601</span> <span class="identifier">ns</span>  <span class="number">368.466</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">2048</span>                    <span class="number">21243</span> <span class="identifier">ns</span>  <span class="number">367.775</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">4096</span>                    <span class="number">42502</span> <span class="identifier">ns</span>  <span class="number">367.631</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">8192</span>                    <span class="number">85239</span> <span class="identifier">ns</span>  <span class="number">366.618</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">16384</span>                  <span class="number">169736</span> <span class="identifier">ns</span>  <span class="number">368.22</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">32768</span>                  <span class="number">340220</span> <span class="identifier">ns</span>  <span class="number">367.409</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">65536</span>                  <span class="number">678907</span> <span class="identifier">ns</span>  <span class="number">368.247</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">131072</span>                <span class="number">1357145</span> <span class="identifier">ns</span>  <span class="number">368.422</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">262144</span>                <span class="number">2720207</span> <span class="identifier">ns</span>  <span class="number">367.635</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">524288</span>                <span class="number">5430141</span> <span class="identifier">ns</span>  <span class="number">368.332</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">1048576</span>              <span class="number">10896708</span> <span class="identifier">ns</span>  <span class="number">367.095</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">2097152</span>              <span class="number">21797935</span> <span class="identifier">ns</span>  <span class="number">367.047</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">4194304</span>              <span class="number">43723059</span> <span class="identifier">ns</span>  <span class="number">365.944</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">8388608</span>              <span class="number">87229180</span> <span class="identifier">ns</span>  <span class="number">366.864</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">16777216</span>            <span class="number">174988864</span> <span class="identifier">ns</span>  <span class="number">365.74</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;</span><span class="identifier">_BigO</span>                    <span class="number">10.42</span> <span class="identifier">N</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">8</span>                       <span class="number">52.4</span> <span class="identifier">ns</span> <span class="number">1.13779</span><span class="identifier">G</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">16</span>                       <span class="number">122</span> <span class="identifier">ns</span> <span class="number">1002.14</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">32</span>                       <span class="number">307</span> <span class="identifier">ns</span> <span class="number">795.253</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">64</span>                       <span class="number">685</span> <span class="identifier">ns</span> <span class="number">712.628</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">128</span>                     <span class="number">1445</span> <span class="identifier">ns</span> <span class="number">675.805</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">256</span>                     <span class="number">2966</span> <span class="identifier">ns</span> <span class="number">658.488</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">512</span>                     <span class="number">6062</span> <span class="identifier">ns</span> <span class="number">644.35</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">1024</span>                   <span class="number">12166</span> <span class="identifier">ns</span> <span class="number">642.173</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">2048</span>                   <span class="number">24336</span> <span class="identifier">ns</span> <span class="number">642.064</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">4096</span>                   <span class="number">48862</span> <span class="identifier">ns</span> <span class="number">639.567</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">8192</span>                   <span class="number">98008</span> <span class="identifier">ns</span> <span class="number">637.708</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">16384</span>                 <span class="number">196394</span> <span class="identifier">ns</span> <span class="number">636.481</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">32768</span>                 <span class="number">392810</span> <span class="identifier">ns</span> <span class="number">636.434</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">65536</span>                 <span class="number">783903</span> <span class="identifier">ns</span> <span class="number">637.859</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">131072</span>               <span class="number">1556741</span> <span class="identifier">ns</span> <span class="number">642.378</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">262144</span>               <span class="number">3121184</span> <span class="identifier">ns</span> <span class="number">640.792</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">524288</span>               <span class="number">6265681</span> <span class="identifier">ns</span> <span class="number">638.404</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">1048576</span>             <span class="number">12421627</span> <span class="identifier">ns</span> <span class="number">644.076</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">2097152</span>             <span class="number">24907611</span> <span class="identifier">ns</span> <span class="number">642.417</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">4194304</span>             <span class="number">49773317</span> <span class="identifier">ns</span> <span class="number">642.934</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">8388608</span>            <span class="number">100034750</span> <span class="identifier">ns</span> <span class="number">639.79</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">16777216</span>           <span class="number">199477349</span> <span class="identifier">ns</span> <span class="number">641.685</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;</span><span class="identifier">_BigO</span>                   <span class="number">11.90</span> <span class="identifier">N</span>
<span class="identifier">BMSimpleOrdinaryLeastSquares</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;</span><span class="identifier">_RMS</span>                        <span class="number">0</span> <span class="special">%</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">8</span>               <span class="number">69.2</span> <span class="identifier">ns</span> <span class="number">441.314</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">16</span>               <span class="number">147</span> <span class="identifier">ns</span> <span class="number">415.939</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">32</span>               <span class="number">356</span> <span class="identifier">ns</span> <span class="number">342.815</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">64</span>               <span class="number">736</span> <span class="identifier">ns</span> <span class="number">331.749</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">128</span>             <span class="number">1494</span> <span class="identifier">ns</span> <span class="number">326.765</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">256</span>             <span class="number">3161</span> <span class="identifier">ns</span> <span class="number">308.909</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">512</span>             <span class="number">6343</span> <span class="identifier">ns</span> <span class="number">307.94</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">1024</span>           <span class="number">12707</span> <span class="identifier">ns</span> <span class="number">307.409</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">2048</span>           <span class="number">25390</span> <span class="identifier">ns</span> <span class="number">307.699</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">4096</span>           <span class="number">50820</span> <span class="identifier">ns</span> <span class="number">307.455</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">8192</span>          <span class="number">101738</span> <span class="identifier">ns</span> <span class="number">307.161</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">16384</span>         <span class="number">203033</span> <span class="identifier">ns</span> <span class="number">307.835</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">32768</span>         <span class="number">403366</span> <span class="identifier">ns</span> <span class="number">309.894</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">65536</span>         <span class="number">767080</span> <span class="identifier">ns</span> <span class="number">325.911</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">131072</span>       <span class="number">1515010</span> <span class="identifier">ns</span> <span class="number">330.034</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">262144</span>       <span class="number">2965539</span> <span class="identifier">ns</span> <span class="number">337.21</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">524288</span>       <span class="number">5774329</span> <span class="identifier">ns</span> <span class="number">346.372</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">1048576</span>     <span class="number">11384267</span> <span class="identifier">ns</span> <span class="number">351.371</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">2097152</span>     <span class="number">22899097</span> <span class="identifier">ns</span> <span class="number">349.406</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">4194304</span>     <span class="number">45923903</span> <span class="identifier">ns</span> <span class="number">348.423</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">8388608</span>     <span class="number">92138186</span> <span class="identifier">ns</span> <span class="number">347.306</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;/</span><span class="number">16777216</span>   <span class="number">183263471</span> <span class="identifier">ns</span> <span class="number">349.226</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;</span><span class="identifier">_BigO</span>           <span class="number">10.94</span> <span class="identifier">N</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;</span><span class="identifier">_RMS</span>                <span class="number">1</span> <span class="special">%</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">8</span>              <span class="number">68.7</span> <span class="identifier">ns</span> <span class="number">887.806</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">16</span>              <span class="number">166</span> <span class="identifier">ns</span> <span class="number">734.816</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">32</span>              <span class="number">385</span> <span class="identifier">ns</span> <span class="number">633.918</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">64</span>              <span class="number">812</span> <span class="identifier">ns</span> <span class="number">601.394</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">128</span>            <span class="number">1774</span> <span class="identifier">ns</span> <span class="number">550.424</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">256</span>            <span class="number">3554</span> <span class="identifier">ns</span> <span class="number">549.562</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">512</span>            <span class="number">7151</span> <span class="identifier">ns</span> <span class="number">546.25</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">1024</span>          <span class="number">14335</span> <span class="identifier">ns</span> <span class="number">545.006</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">2048</span>          <span class="number">28608</span> <span class="identifier">ns</span> <span class="number">546.163</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">4096</span>          <span class="number">57228</span> <span class="identifier">ns</span> <span class="number">546.067</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">8192</span>         <span class="number">113732</span> <span class="identifier">ns</span> <span class="number">549.537</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">16384</span>        <span class="number">227686</span> <span class="identifier">ns</span> <span class="number">549.004</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">32768</span>        <span class="number">453989</span> <span class="identifier">ns</span> <span class="number">550.668</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">65536</span>        <span class="number">901696</span> <span class="identifier">ns</span> <span class="number">554.517</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">131072</span>      <span class="number">1771910</span> <span class="identifier">ns</span> <span class="number">564.365</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">262144</span>      <span class="number">3430961</span> <span class="identifier">ns</span> <span class="number">582.933</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">524288</span>      <span class="number">6751237</span> <span class="identifier">ns</span> <span class="number">592.511</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">1048576</span>    <span class="number">13544819</span> <span class="identifier">ns</span> <span class="number">590.639</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">2097152</span>    <span class="number">27331142</span> <span class="identifier">ns</span> <span class="number">585.422</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">4194304</span>    <span class="number">54944987</span> <span class="identifier">ns</span> <span class="number">582.425</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">8388608</span>   <span class="number">109574257</span> <span class="identifier">ns</span> <span class="number">584.087</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;/</span><span class="number">16777216</span>  <span class="number">221449209</span> <span class="identifier">ns</span> <span class="number">578.003</span><span class="identifier">M</span><span class="special">/</span><span class="identifier">s</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;</span><span class="identifier">_BigO</span>          <span class="number">13.17</span> <span class="identifier">N</span>
<span class="identifier">BMSimpleOrdinaryLeastSquaresWRSquared</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;</span><span class="identifier">_RMS</span>               <span class="number">1</span> <span class="special">%</span>
</pre>
</div>
<div class="copyright-footer">Copyright © 2006-2021 Nikhar Agrawal, Anton Bikineev, Matthew Borland,
      Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert Holin, Bruno
      Lalande, John Maddock, Evan Miller, Jeremy Murphy, Matthew Pulver, Johan Råde,
      Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg, Daryle
      Walker and Xiaogang Zhang<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="ljung_box.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../statistics.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="chatterjee_correlation.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
